package com.wenyang.service.impl;

//import com.github.pagehelper.PageHelper;
//import com.github.pagehelper.PageInfo;
import com.wenyang.dao.RouteDao;
import com.wenyang.entity.TabRoute;
import com.wenyang.entity.VO.TabRouteVo;
import com.wenyang.service.RouteService;
import com.wenyang.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @Author zx
 * @Date 2024/3/20 9:09
 * @Version 1.0
 */

@Service
public class RouteServiceImpl implements RouteService{

    @Autowired
    private RouteDao routeDao;

    /**
     * 查询所有路线信息
     * @return
     */
    @Override
    public List<TabRoute> findAll() {
        String url = "https://20240416-wenyangfile.oss-cn-beijing.aliyuncs.com/";
        List<TabRoute> tabRoutes = new ArrayList<>();
        List<TabRoute> tabRouteList = routeDao.findAll();
        for (TabRoute tabRoute : tabRouteList) {
            tabRoute.setRimage(url + tabRoute.getRimage());
            tabRoutes.add(tabRoute);
        }
        return tabRoutes;
    }


    /**
     * 分页查询所有旅游路线
     * @param startIdx
     * @param size
     * @param rname
     * @return
     */
    @Override
    public List<TabRoute> listByPage(int startIdx, int size, String rname) {
        return routeDao.listByPage(startIdx,size,rname);
    }

    @Override
    public int saveRoute(TabRouteVo tabRouteVo) {
        return routeDao.saveRoute(tabRouteVo);
    }

    @Override
    public String removeRoute(String ids) {
        return routeDao.removeRoute(ids);
    }

}
